<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>密码修改</title>
<script type="text/javascript" src="../script/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../script/sha1.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $("#CON_BUTTON").click(function() {

        	$("#OLDPASS_MSG").text("");
        	$("#NEWPASS_MSG").text("");
            $("#NEWPASSCON_MSG").text("");
            
            var reg = /^[a-zA-Z0-9]{6,12}$/;
            if (!reg.test($("#NEWPASS_TEXT").val())) {
            	$("#NEWPASS_MSG").text("允许字符0-9、a-z、A-Z，长度6-12");
                return;
            }
            
            $.getJSON("ModifyPassword.action",
            	{
                    "oldPassword" : hex_sha1($("#OLDPASS_TEXT").val()),
                    "newPassword" : hex_sha1($("#NEWPASS_TEXT").val()),
                    "newPasswordConfirm" : hex_sha1($("#NEWPASSCON_TEXT").val())
            	},
                function(data) {
                    if (data.status == "failure") {
                        if (data.failType == "OLDPASSWRONG") {
                            $("#OLDPASS_MSG").text("密码错误");
                        } else if (data.failType == "NEWPASSCONWRONG") {
                        	$("#NEWPASSCON_MSG").text("两次输入不一致");
                        }
                    } else if (data.status == "success") {
                        $("#MODIFYPASS_DIV").text("修改密码成功，请牢记新密码");
                    } else if (data.status == "error") {
                    	$("#MODIFYPASS_DIV").text("修改密码失败，请稍后重试");
                    }
            	}
            );
        });
    });
</script>
<style type="text/css">
    .redTx {
        color: red;
    }
</style>
</head>
<body>
<div id="MODIFYPASS_DIV">
    <ul style="list-style: none; margin-left: 10px;">
        <li>*原密码：&nbsp;&nbsp;&nbsp;&nbsp;<input type="password" name=oldPassword" id="OLDPASS_TEXT"/><span id="OLDPASS_MSG" class="redTx"></span></li>
        <li>*新密码：&nbsp;&nbsp;&nbsp;&nbsp;<input type="password" name=newPassword" id="NEWPASS_TEXT"/><span id="NEWPASS_MSG" class="redTx"></span></li>
        <li>*新密码确认：<input type="password" name="newPasswordConfirm" id="NEWPASSCON_TEXT"/><span id="NEWPASSCON_MSG" class="redTx"></span></li>
        <li><input type="button" id="CON_BUTTON" value="修改"/></li>
    </ul>
</div>
</body>
</html>